
package com.coo.tao.web.interceptor;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 李志鹏
 * @ClassName: CommonInterceptor
 * @Description: TODO
 * @date 2011-7-18 下午05:32:47
 */
public class CommonInterceptor extends HandlerInterceptorAdapter {

    private static Logger log = Logger.getLogger(CommonInterceptor.class);
    
    private long start_time=0L;
    private String view_url;
    /**
     * 方法执行前的拦截方法
     */
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    	start_time = System.currentTimeMillis();
    	view_url= request.getRequestURI();
        log.info("===========>go Interceptor：" + view_url);
        return true;
    } 
    public void postHandle(
			HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
			throws Exception {
    	 log.info("===========>go Interceptor：" + view_url+" cost time:"+(System.currentTimeMillis()-start_time));
	}
    public static void main(String[] args) {
      
    }

}
